package com.ruoyi.library.controller;

import javax.annotation.Resource;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.library.api.query.DigitalTwinAssetsQuery;
import com.ruoyi.library.api.vo.DigitalTwinAssetsVO;
import com.ruoyi.library.domain.DtsDigitalTwinAssets;
import com.ruoyi.library.service.IDtsDigitalTwinAssetsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 资产
 *
 * @author ZhangYu
 * @date 2024-05-16
 */
@Api(tags = "资产")
@RestController
@RequestMapping("/assets")
public class DtsDigitalTwinAssetsController {

    @Resource
    private IDtsDigitalTwinAssetsService digitalTwinAssetsService;

    /**
     * 资产信息分页
     *
     * @param digitalTwinAssetsQuery 空间信息查询条件
     * @return 资产信息分页
     */
    @ApiOperation("资产信息分页")
    @GetMapping("/page")
    public R<Page<DigitalTwinAssetsVO>> assetsInfoPage(DigitalTwinAssetsQuery digitalTwinAssetsQuery) {
        Page<DigitalTwinAssetsVO> assetsInfoPage = digitalTwinAssetsService.assetsInfoPage(digitalTwinAssetsQuery);
        return R.ok(assetsInfoPage);
    }

    /**
     * 资产详情
     *
     * @param id 唯一主键
     * @return 资产详情
     */
    @ApiOperation("资产详情")
    @GetMapping("/info")
    public R<DigitalTwinAssetsVO> getAssetsInfoById(@RequestParam Long id) {
        DtsDigitalTwinAssets digitalTwinAssets = digitalTwinAssetsService.getById(id);
        return R.ok(BeanUtil.copyProperties(digitalTwinAssets, DigitalTwinAssetsVO.class));
    }

}
